<script lang="ts" setup>
import {getByIdOrderDetail} from "../serve.ts"
import {useRoute} from 'vue-router'
import {ref} from "vue"

const
    route = useRoute(),
    listLoading = ref(false),
    itemData: any = ref([])
;

function get() {
  listLoading.value = true
  if (route.query['id']) {
    getByIdOrderDetail(route.query['id']).then((r: any) => {
      itemData.value = r
      listLoading.value = false
    }).catch(() => listLoading.value = false)
  }
}

get()
</script>

<template>
  <el-scrollbar>
    <el-card>
      <el-table v-loading="listLoading" :data="itemData"
                :header-cell-style="{ fontWeight: 'bold' }" element-loading-text="加载中..." size="small">
        <el-table-column align="center" label="订单id" min-width="100" prop="id"/>
        <el-table-column align="center" label="图片" min-width="80">
          <template #default="scope">
            <el-image v-show="!!scope.row.image" :hide-on-click-modal="true"
                      :preview-src-list="[scope.row?.image]" :src="scope.row.image" fit="cover" preview-teleported
                      style="width: 60px; height: 60px;border-radius: 5px;"/>
            <el-image v-show="!scope.row?.image" fit="cover"
                      src="https://cube.elemecdn.com/e/fd/0fc7d20532fdaf769a25683617711png.png"
                      style="width: 60px; height: 60px;border-radius: 5px;"/>
          </template>
        </el-table-column>
        <el-table-column align="center" label="购买数量" prop="payNum" width="80"/>
        <el-table-column align="center" label="实付单价" min-width="80" prop="price"/>
        <el-table-column align="center" label="鲜花名称" min-width="140" prop="productName"/>
      </el-table>
    </el-card>
  </el-scrollbar>
</template>

<style lang="scss" scoped>

</style>